<?php
/**
 *
 * @author: Pako
 * @Email: admin@jqcool.net
 * @Date: 18-10-15 下午11:26
 */

namespace App\Http\Request\Order;

use App\Http\Request\Store;

class OrderStore extends Store
{
    public function rules()
    {
        $data = [
            'loan_limit' => 'required|integer',
            'product_id' => 'required|integer',
            'loan_date_limit' => 'required|integer',
            'indentity' => 'required|integer',
            'local_accumulation' => 'required|integer',
            'house_type' => 'required|integer',
            'had_car' => 'required|integer',
            'credit' => 'required|integer',
            'city_code' => 'required|integer',
            'had_insurance' => 'required|integer',
            'had_mortgage' => 'required|integer',
            'tel' => 'required|regex:/^1[345678]\d{9}$/',
            'loan_type' => 'required|integer',
            'access_service' => 'required|integer',
        ];

        $method = strtoupper($this->method());

        if ($method == 'PUT') {
            $data['order_number'] = 'required|integer';
        }

        return $data;
    }


    public function attributes()
    {
        return [
            'loan_limit' => '贷款额度',
            'product_id' => '产品ID',
            'loan_date_limit' => '贷款期限',
            'indentity' => '职业身份',
            'local_accumulation' => '公积金',
            'house_type' => '名下房产',
            'had_car' => '是否有车',
            'credit' => '信用情况',
            'city_code' => '城市码',
            'had_insurance' => '购买商业保险',
            'had_mortgage' => '是否有抵押贷款',
            'tel' => '联系方式',
            'loan_type' => '贷款类型',
            'access_service' => '是否接受贷款协议',
        ];
    }
}